﻿using Bank.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Bank.VariableTemplate
{
    public class VariableTiles : DataTemplateSelector
    {
        public DataTemplate MyAccountTileTemplate { get; set; }
        public DataTemplate ServicesTileTemplate { get; set; }
        public DataTemplate CreditCardTileTemplate { get; set; }
        public DataTemplate FixedDepositTileTemplate { get; set; }
       
        protected override Windows.UI.Xaml.DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;
            if (item != null && element != null)
            {

                if (item.GetType() == typeof(SampleDataItem))
                {

                if ((item as SampleDataItem).UniqueId.StartsWith("MyAccountTile"))
                        return MyAccountTileTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("ServicesTile"))
                        return ServicesTileTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("CreditCardTile"))
                    return CreditCardTileTemplate;

                }

                else if (item.GetType() == typeof(GroupDetailDataItem))
                {

                    if ((item as GroupDetailDataItem).UniqueId.StartsWith("MyAccountTile"))
                        return MyAccountTileTemplate;

                    if ((item as GroupDetailDataItem).UniqueId.StartsWith("FixedDepositTile"))
                        return FixedDepositTileTemplate;
                }
            }

            return base.SelectTemplateCore(item, container);
        }
    }
}
